﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="ManagerAccount.aspx.cs" Inherits="ManagerAccount" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
<style>
    section#bg_content{ padding:0}
    .bg01{ border:0 none;}
    </style>
 <link href="js/validationEngine.jquery.css" rel="stylesheet" type="text/css" />
    <script src="js/jquery.validationEngine.js" type="text/javascript"></script>
    <script src="js/jquery.validationEngine-en.js" type="text/javascript"></script>
<script>
    $(document).ready(function () {
        jQuery(".form").validationEngine({ scroll: false, focusFirstField: false });

    });

    function LoadUser(userid) {
        $.ajax({
            type: "POST",
            url: "PIMService.asmx/GetUserById",
            data: "{'_userId':'" + userid + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (result) {
                var user = result.d;
                var username = user.UserName;
                var Password = user.Password;
                $('#manager_username').val(username);
                $('#manager_old_password').val(Password);
            },
            error: function (result) {
                alert('Error');
            }
        });
    }

    function changepass(userid) {
        $('#changepassword').click(function () {
            if (!$("#changepassword").validationEngine('validate')) {
                return false;
            }
            $.ajax({
                type: "POST",
                url: "PIMService.asmx/ChangePassword",
                data: "{'_userId':'" + userid + "','_password':'" + $("#manager_new_password").val() + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (result) {
                    if (result.d == 'NotOK' || result.d == '') {
                        alert('Change password is fail!');
                    }
                    else {
                        self.location = "Default.aspx"
                    }
                },
                error: function (result) {
                    alert('Can not change password!');
                }
            });

        });
    }

    function customValidate(field, rules, i, options) {
        var pattern = new RegExp(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/);
        var match = pattern.exec(field.val());
        if (field.val() == "") {
            return true;
        }
        else if (match == null) {
            return options.allrules.email.alertText;
        }
    }

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<section id="bg_content">
<div id="content" class="clearfix">
        <div class="alpha01 clearfix">
            <div class="bg01">
                <div class="bg02">
                    <%--<div class="bg03 clearfix">--%>
                    <div class="bg03 clearfix" style="padding:10px;">
                        <form method="post" action="#">
                        <div >
                        <div class="accountdiv">
                            <p class="title01">Change Password</p>
                        </div>
                        <div class="accountdiv">
                            <div class="text-field">
                            Email Address:
                            </div>
                            <div class="ip-text">
                            <input class="input-trpr" name="email" id="manager_username" readonly="readonly" type="text" autocomplete="on"
                                placeholder="Email address">
                            </div>
                        </div>
                        <div style="clear:both"></div>
                        <div class="accountdiv">
                            <div class="text-field">
                            Old Password:
                            </div>
                            <div class="ip-text">
                            <input  class="input-trpr" name="oldpassword" id="manager_old_password" readonly="readonly" type="password"
                                placeholder="Password">
                            </div>
                        </div>
                        <div style="clear:both"></div>
                        <div class="accountdiv">
                            <div class="text-field">
                            New Password:
                            </div>
                            <div class="ip-text">
                                <input  class="validate[required,minSize[5],maxSize[50]] input-trpr" name="newpassword" id="manager_new_password" type="password">
                            </div>
                        </div>
                        <div style="clear:both"></div>
                        <div class="accountdiv">
                            <div class="text-field">
                            Confirm New Password:
                            </div>
                            <div class="ip-text">
                            <input  class="validate[required,equals[manager_new_password]] input-trpr" name="confirmnewpassword" id="manager_confirm_new_password" type="password"
                                >
                            </div>
                        </div>
                        <div style="clear:both"></div>
                        <div class="accountdiv" style="text-align:center; margin-top:10px;">
                            <input  id="changepassword" class="button-form" value="Change password" type="button" />
                        </div>
                        </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
</asp:Content>

